;(function(window, document) {
    angular
        .module('app')
        .factory('userAgentFactory', userAgentFactory);

    function userAgentFactory () {
        var service = {};
        service.getUA = function () {
            return navigator.userAgent.toLowerCase();
        };
        service.getOS = function (isDetail) {
            var osType = 'Not in list';

            if (isDetail !== null && isDetail !== undefined) {
                isDetail = isDetail;
            } else {
                isDetail = 0;
            }

            if (this.getUA().indexOf('iphone') > -1) {
                osType = isDetail ? 'iphone' : 'ios';
            }
            if (this.getUA().indexOf('ipad') > -1) {
                osType = isDetail ? 'ipad' : 'ios';
            }
            if (this.getUA().indexOf('android') > -1) {
                osType = 'android';
            }

            return osType;
        };

        return service;
    }
})(window, document);
